package exam.springsecurity.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/4/3 21:04
 * @since JDK 1.8
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("user")
@ApiModel("用户模块")
public class User implements UserDetails,Serializable {

    @ApiModelProperty("主键id")
    @TableId(value = "id",type = IdType.ASSIGN_UUID)
    private String uuid;

    @ApiModelProperty("账号")
    @TableField("username")
    private String userName;

    @ApiModelProperty("密码")
    @TableField("password")
    private String passWord;

    @ApiModelProperty("用户姓名")
    @TableField("realname")
    private String realName;

    @ApiModelProperty("用户手机号")
    @TableField("phone")
    private String phone;

    @ApiModelProperty("用户状态")
    @TableField("status")
    private Integer status;

    @ApiModelProperty("创建时间")
    @TableField("createTime")
    private String createTime;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return passWord;
    }

    @Override
    public String getUsername() {
        return userName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
